package com.spddr.pmos.rpt.pojo;

import java.io.Serializable;

import org.joda.time.DateTime;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

import cn.seqdata.tags.Point;
import cn.seqdata.tags.PointValue;
import cn.seqdata.tags.QualityPart;
import cn.seqdata.tags.common.IdTags;

@JsonInclude(Include.NON_NULL)
public class CellValue implements Serializable {
	private static final long serialVersionUID = 1L;

	private String metric;
	private String metricName;
	private long object;
	private String objectName;
	private DateTime timestamp;
	private Number value;

	public CellValue() {
	}

	public CellValue(PointValue<IdTags, Point<IdTags>> pval, String metricName, String objectName) {
		this(pval.getKey(), pval.getValue(), metricName, objectName);
	}

	public CellValue(Point<IdTags> key, QualityPart value, String metricName, String objectName) {
		this.metricName = metricName;
		this.objectName = objectName;
		this.metric = key.getMetric();
		this.object = key.getTags().getId();
		this.timestamp = value.getTimestamp();
		this.value = value.getValue();
	}

	public String getMetric() {
		return metric;
	}

	public void setMetric(String metric) {
		this.metric = metric;
	}

	public String getMetricName() {
		return metricName;
	}

	public long getObject() {
		return object;
	}

	public void setObject(long object) {
		this.object = object;
	}

	public String getObjectName() {
		return objectName;
	}

	public DateTime getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(DateTime timestamp) {
		this.timestamp = timestamp;
	}

	public Number getValue() {
		return value;
	}

	public void setValue(Number value) {
		this.value = value;
	}

	@JsonIgnore
	public PointValue<IdTags, Point<IdTags>> toPointValue() {
		Point<IdTags> point = new Point<>(metric, new IdTags(object));
		return new PointValue<>(point, value, timestamp);
	}
}
